package com.miot.restapi.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @Author: zhangyanbin
 * @Date: 2019/1/9 14:32
 * @Version 1.0
 */
@Configuration
@EnableSwagger2
@Profile({"dev","prod"})
public class Swagger2Config {

    private final static String basePackage = "com.miot.restapi.controller";
    private final static String title = "智慧家居";
    private final static String description = "智能家居";
    private final static String version = "V1.0";

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo()).select().apis(RequestHandlerSelectors.basePackage(basePackage))
                .paths(PathSelectors.any()).build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder().title(title)
                .description(description).contact("智慧房间").version(version).build();
    }
}
